import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//比较student类
class Student implements Comparable<Student>{
    private String name;
    private String body;
    private int  id;

    public Student(String name, String body, int  id) {
        this.name = name;
        this.body = body;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public double getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", body='" + body + '\'' +
                ", id=" + id +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.id-o.id;
    }
}
//自定义异常
class MyException extends RuntimeException {
    public MyException(){
        super();
    }
}



public class HomeWork {

    public static void main1(String[] args) {
        Student student1 = new Student("亚索", "1601", 100);
        Student student2 = new Student("泰隆", "1601", 99);
        Student student3 = new Student("齐天大圣", "1601", 98);
        Student student4 = new Student("无极剑圣", "1601", 96);
        ArrayList<Student> students = new ArrayList<>();
        students.add(student1);
        students.add(student2);
        students.add(student3);
        students.add(student4);
        System.out.println(students);
        Collections.sort(students);
        System.out.println(students);

    }

    //面试真题
    //删除s1中的s2出现的字符
    public static void main2(String[] args) {
        String s1 = "welcome to bt";
        String s2 = "come";
       List<Character> list = new ArrayList<>();
       for(int i = 0; i<s1.length();++i){
           char ch = s1.charAt(i);
           if(!s2.contains(ch+""))
                list.add(ch);
       }
        System.out.println(list);

    }


    public static void main3(String[] args) {
        String tname = "王文";
        String tpin = "159217";
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = scanner.nextLine();
        System.out.println("请输入密码：");
        String pin = scanner.nextLine();
        if(name.equals(tname)||pin.equals(tpin)){
            throw new MyException();
        }

    }

}
